﻿<script type="text/javascript">
    $(document).ready(function () {
        $("#MenuNews").removeClass("dropdown").addClass("active");
    });
</script>
@model IEnumerable<DatNuocViet.Models.SearchNewsResult>
@{
    ViewBag.Title = "Dat Nuoc Viet";
}
<div class="contenttitle">
    <div class="titleplace">
        <span>Danh sách bài viết</span>&nbsp;&nbsp;&nbsp;
        @if (ViewBag.message != null)
        {
            <span style="font-weight:600;color:Red;">@ViewBag.message</span>
        }
    </div>
    <div class="buttonplace">
        <a href="@Url.Action("CreateNews","AdminNews")">
            <input type="button" value="Thêm bài viết" />
        </a>
    </div>
    <div class="clear">&nbsp;</div>
</div>
<div class="contentitem">
    @using (Html.BeginForm("News", "AdminNews", FormMethod.Get))
    {
        <p>
            <span style="font-weight:600;">Tìm kiếm</span>&nbsp;
            <input type="text" class="input250" name="KeyWord" id="KeyWord"/>
            <select name="NewsType" id="NewsType">
                <option value="-1">Tất cả</option>
                @foreach(var item in (List<DatNuocViet.Models.GetNewsTypeResult>)ViewBag.NewsType)
                {
                    <option value="@item.Id">@item.NewsTypeVn</option>
                }
            </select>
            <input type="submit" value="Tìm kiếm" /> 
        </p>    
    }
    <table class="tablecontent">
        <thead>
            <tr>
                <th style="width:50px;">
                    &nbsp;
                </th>
                <th>
                    Tên bài việt
                </th>
                <th style="width:250px;">
                    Loại tin
                </th>
                <th style="width:70px;">
                    &nbsp;
                </th>
            </tr>            
        </thead>
        <tbody id="tablecontent">
            @{int i = 0;}
            @foreach (var item in Model)
            {
                i++;
                <tr class="@(i%2==0?"event":"odd")">
                    <td>
                        @(((int)ViewBag.PageIndex - 1) * 20 + i) 
                    </td>
                    <td>
                        @item.TitleVn
                    </td>
                    <td>
                        @item.NewsTypeVn
                    </td>
                    <td>
                        @Html.ActionLink("Chỉnh sửa", "EditNews", new { id = item.NewsId })
                    </td>
                </tr>
            }
        </tbody>
        <tfoot>
            <tr>
                <td colspan="4">
                    <div class="pagination" id="paging">
                        <a class="@((int)ViewBag.PageIndex==1?"current":"")" href="@((int)ViewBag.PageIndex == 1 ? "javascript:void(0)" : Url.Content("~/Admin/AdminNews/News?Page=1&KeyWord=" + (string)ViewBag.KeyWord + "&NewsType=" + ViewBag.CurrentType))">Trang đầu</a>
                        @for (int j = 1; j <= (int)ViewBag.TotalPage; j++)
                        {
                            <a class="@((int)ViewBag.PageIndex==j?"current":"")" href="@((int)ViewBag.PageIndex == j ? "javascript:void(0)" : Url.Content("~/Admin/AdminNews/News?Page=" + j + "&KeyWord=" + (string)ViewBag.KeyWord + "&NewsType=" + ViewBag.CurrentType))">@j</a>                            
                        }
                        <a class="@(ViewBag.PageIndex == ViewBag.TotalPage ? "current" : "")" href="@(ViewBag.PageIndex == ViewBag.TotalPage ? "javascript:void(0)" : Url.Content("~/Admin/AdminNews/News?Page=" + ViewBag.TotalPage + "&KeyWord=" + (string)ViewBag.KeyWord + "&NewsType=" + ViewBag.CurrentType))">Trang cuối</a>
                    </div>
                </td>
            </tr>
        </tfoot>
    </table>
</div>
